package main

import (
    "io/ioutil"
    "fmt"
    "http"
    "io"
    "web" 
)

func bye(ctx *web.Context){
    res,err := http.PostForm("http://fantasyherald.com/quiz/dand/index.php",ctx.Request.Params)
    if err == nil {
        io.Copy(ctx,res.Body)
        defer res.Body.Close()
    }
    return
}

func main() {
    fmt.Printf("start\n")
    out,err := ioutil.ReadFile("./index.php")
    if (err != nil){
        return
    }
    s := string(out)
	hello := func () string {
		return s
	}
    web.Get("/", hello)
    web.Get("/dnd/dnd.go", hello)
    web.Post("/dnd/dnd.go", bye)
    web.RunFcgi("127.0.0.1:9001")
    //web.Run("0.0.0.0:9000")
}

